//
//  SZuodaTableViewCell.m
//  News
//
//  Created by dlios on 15-5-14.
//  Copyright (c) 2015年 PEAK. All rights reserved.
//

#import "SZuodaTableViewCell.h"
#import "UIImageView+WebCache.h"
@implementation SZuodaTableViewCell

- (void)dealloc
{
    [_zuos release];
    [_zuox release];
    [_you release];
    [_biaoti release];
    [_myView release];
    [_xiangqing release];
    [_laiyuan release];
    [_zshu release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.myView = [[[UIView alloc] init] autorelease];
       // _myView.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:_myView];
        self.zuos = [[[UIImageView alloc] init] autorelease];
       // _zuos.backgroundColor = [UIColor redColor];
        [_myView addSubview:_zuos];
        self.you = [[[UIImageView alloc] init] autorelease];
       // _you.backgroundColor = [UIColor blueColor];
        [_myView addSubview:_you];
        self.zuox = [[[UIImageView alloc] init] autorelease];
       // _zuox.backgroundColor = [UIColor cyanColor];
        [_myView addSubview:_zuox];
        self.xiangqing = [[[UILabel alloc] init] autorelease];
        _xiangqing.numberOfLines = 0;
      //  _xiangqing.backgroundColor = [UIColor orangeColor];
        [_myView addSubview:_xiangqing];
        self.biaoti = [[[UILabel alloc] init] autorelease];
      //  _biaoti.backgroundColor = [UIColor greenColor];
        [_myView addSubview:_biaoti];
        self.laiyuan = [[[UILabel alloc] init] autorelease];
      //  _laiyuan.backgroundColor = [UIColor redColor];
        [_myView addSubview:_laiyuan];
        self.zang = [UIButton buttonWithType:UIButtonTypeSystem];
       [_zang setImage:[UIImage imageNamed:@"iconfont-dianzan"] forState:UIControlStateNormal];
            [_myView addSubview:_zang];
        self.zshu = [[[UILabel alloc] init] autorelease];
        //_zshu.backgroundColor = [UIColor greenColor];
        [_myView addSubview:_zshu];

        
    }
    return self;
}

- (void)layoutSubviews
{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    [super layoutSubviews];
     self.myView.frame = CGRectMake(10, 10, self.contentView.bounds.size.width - 20, self.contentView.bounds.size.height - 20);
    self.you.frame = CGRectMake(_myView.bounds.size.width - ( _myView.bounds.size.width / 2 + 20), 0, _myView.bounds.size.width / 2 + 25, _myView.bounds.size.height / 2 + 25);
    
    self.zuos.frame = CGRectMake(0, 0, _you.bounds.size.width - 48, _you.bounds.size.height / 2 );
    
    self.zuox.frame = CGRectMake(0, self.zuos.frame.size.height, _you.bounds.size.width - 48, _you.bounds.size.height / 2 );
    
    self.biaoti.frame =CGRectMake(0, _you.bounds.size.height + 5, _myView.bounds.size.width, 22);
    self.xiangqing.frame = CGRectMake(0, _biaoti.bounds.size.height + _you.bounds.size.height + 5, _myView.bounds.size.width, _myView.bounds.size.height - _you.bounds.size.height - 44);
    _xiangqing.numberOfLines = 0;
//    self.laiyuan.frame = CGRectMake(0, self.xiangqing.frame.size.height +  _you.frame.size.height + _biaoti.frame.size.height , 120, 20);
//    self.laiyuan.frame =  CGRectMake(0, self.myView.bounds.size.height - 26, self.myView.bounds.size.width - 75, 22);
//    _zang.frame =CGRectMake(self.myView.bounds.size.width - 80, self.myView.bounds.size.height - 26, 22, 22);
//    [_zang setTintColor:[UIColor redColor]];
//      _zshu.frame = CGRectMake(self.myView.bounds.size.width - 40, self.myView.bounds.size.height - 26, self.myView.bounds.size.width - 102, 22);
    _zang.frame = CGRectMake(self.myView.bounds.size.width - 80, self.myView.bounds.size.height - 20, 20, 20);
    [_zang setTintColor:[UIColor redColor]];
    _laiyuan.frame = CGRectMake(0, self.myView.bounds.size.height - 20, 120, 20);
    _zshu.frame = CGRectMake(self.myView.bounds.size.width - 40, self.myView.bounds.size.height - 20, 60, 20);
    
   }
//重写read  Set方法
- (void)setRead:(SRead *)read
{
    if (_read != read) {
        [_read release];
        _read = [read retain];
    }
    
    _xiangqing.text = read.digest;
    _biaoti.text = read.title;
    [_you sd_setImageWithURL:[NSURL URLWithString:read.img]placeholderImage:[UIImage imageNamed:@"``_3(NZ4U{L@4L7FN0J70DA"]];

    NSString *yitu = [read.imgnewextra[0]objectForKey:@"imgsrc"];
    [_zuos sd_setImageWithURL:[NSURL URLWithString:yitu]placeholderImage:[UIImage imageNamed:@"``_3(NZ4U{L@4L7FN0J70DA"]];
    NSString *ertu = [read.imgnewextra[1] objectForKey:@"imgsrc"];
    [_zuox sd_setImageWithURL:[NSURL URLWithString:ertu]placeholderImage:[UIImage imageNamed:@"``_3(NZ4U{L@4L7FN0J70DA"]];
    _laiyuan.text = read.source;
    NSString *str = [NSString stringWithFormat:@"%@", read.upTimes];
    
    _zshu.text = str;

}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
